package com.fengpb.friday.conductor.common.utils;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * IP工具
 */
public class IPUtils {

    public static final Logger log = LoggerFactory.getLogger(IPUtils.class);

    public static String getIP() {
        InetAddress address;
        try {
            address = InetAddress.getLocalHost();
        } catch (UnknownHostException e) {
            log.warn("get local address error", e);
            return "127.0.0.1";
        }
        return address.getHostAddress();
    }
}
